package net.wanho.client;

import net.wanho.config.MyLoadBalancerConfig;
import net.wanho.entity.User;
import net.wanho.vo.AjaxResult;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Author：汤小洋
 * Date：2023-11-09 15:06
 * Description：<描述>
 */
@FeignClient(value = "cloud-gateway", fallback = UserClientFallback.class) // 指定服务提供者的名称
@LoadBalancerClients(defaultConfiguration = MyLoadBalancerConfig.class) // 指定负载均衡策略
public interface UserClient {

    @GetMapping("/users/test")
    public String test();

    @GetMapping("/users")
    AjaxResult getUserList(@RequestParam("username") String username); // 传递参数时，必须指定参数名称

    @DeleteMapping("/users/{id}")
    AjaxResult deleteUser(@PathVariable("id") Integer id);

    @PostMapping("/users")
    AjaxResult addUser(@RequestBody User user);

    @PutMapping("/users")
    AjaxResult modifyUser(@RequestBody User user);

    @GetMapping("/users/query")
    AjaxResult findUser(@RequestParam Map<String, Object> map);
}
